package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.PlantVO;
import com.digitalchina.lxnsy.interfaces.IMyNhbPos;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：白彦东
 * 创建时间：2016/12/28 18:10
 * 修改备注：
 * ================================================
 */

public class BasicInfoPlantHolder extends BaseViewHolder<PlantVO> {

    private TextView tvType;
    private TextView tvVariety;
    private TextView tvArea;
    private TextView tvNum;
    private TextView tvEdit;
    private TextView tvDel;
    private IMyNhbPos callBack;

    public BasicInfoPlantHolder(ViewGroup parent, IMyNhbPos callBack) {
        super(parent, R.layout.item_basic_info_plant);
        tvType = $(R.id.tv_type);
        tvVariety = $(R.id.tv_variety);
        tvArea = $(R.id.tv_area);
        tvNum = $(R.id.tv_num);
        tvEdit = $(R.id.tv_edit);
        tvDel = $(R.id.tv_del);
        this.callBack = callBack;
    }

    @Override
    public void setData(PlantVO data) {
        super.setData(data);
        tvType.setText(data.getCropName());
        tvVariety.setText(data.getVarietyName());
        tvArea.setText(String.format("%s（亩）", data.getPlantArea()));
        tvNum.setText(String.format("%s（kg）", data.getOrderNum()));
        tvEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                callBack.edit(getAdapterPosition());
            }
        });
        tvDel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                callBack.del(getAdapterPosition());
            }
        });
    }

}
